<template>
	<view class="Recommend">
		<view class="team-top">
			<view>当日扣减</view>
			<view>管理分：<text class="number">{{curr_score}}</text></view>
		</view>
		<view class="team-list">
			<view class="list" v-for="(item,index) in socrelist" :key="index">
				<view class="left">
					<text class="name">用户名</text>
					<text class="text">{{item.nickname}}</text>
				</view>
				<view class="cont">
					<text class="name">是否抢单成功</text>
					<text class="text">{{item.type_name}}</text>
				</view>
				<view class="right">
					<text class="name">管理分</text>
					<text class="text">{{item.score}}</text>
				</view>
			</view>
<uni-load-more :loadingType="loadingType" :contentText="contentText"></uni-load-more>
		</view>
	</view>
</template>

<script>
	import uniLoadMore from '../../components/uni-load-more.vue'
	export default {
		components: {
			uniLoadMore
		},
		data() {
			return {
				socrelist: [],
				curr_score:'',
				loadingType: 0,
				contentText: {
					contentdown: "上拉显示更多",
					contentrefresh: "正在加载...",
					contentnomore: "没有更多数据了"
				},
				page: 1,
				loadmore: false, //是否加载
			};
		},
		onLoad() {
			this.getData(this.page);

		},
		methods: {
			getData: function(page) {
				const _this = this;
				//获取管理分
				const data = {
					page:page
				}
				this.$request.get("/api/ucenter/getScoreList", {
					data:data
				})
					.then(res => {
						if (res.data.code == 1) {
							_this.curr_score = res.data.data.curr_sub_score
							// _this.socrelist = res.data.data.list;
							//循环遍历,将新数组追加到list数组中  
							for (let i = 0; i < res.data.data.list.length; i++) {
								_this.socrelist.push(res.data.data.list[i])
							}
							//如果数组长度不够10条就停止加载
							if (res.data.data.list.length < 10) {
								_this.loadmore = true;
							}
						}
					})
					.catch(error => {
						console.error('error:', error);
					});
			},
		},
		onReachBottom() { //上啦加载函数
			let _this = this;
			if (this.loadingType !== 0) {
				return;
			}
			this.page++;
			this.loadingType = 1;
			this.getData(this.page)
			setTimeout(() => {
				//如果数据已经加载完就停止加载.
				if (_this.loadmore) {
					this.loadingType = 2;
					return;
				}
				this.loadingType = 0;
			}, 1000);
		},
	}
</script>

<style lang="less">
	.Recommend {
		background-color: #F1F1F1;
		width: 100%;
		display: flex;
		flex-direction: column;
		align-items: center;

		.team-top {
			width: 100%;
			height: 50px;
			background-color: #FFFFFF;
			display: flex;
			align-items: center;
			justify-content: space-around;
			border-top: 5px solid #F1F1F1;
			border-bottom: 10px solid #F1F1F1;
			font-size: 14px;
			color: #1F3F59;

			.number {
				color: #D14B64;
			}
		}

		.team-list {
			width: 100%;
			background-color: #FFFFFF;
			flex: 1;
			font-size: 12px;
			color: #24435D;

			.list {
				display: flex;
				align-items: center;
				height: 70px;
				border-bottom: 1px solid #F1F1F1;
				line-height: 26px;

				.left {
					flex: 1;
					display: flex;
					flex-direction: column;
					padding-left: 10px;
				}

				.cont {
					flex: 2;
					display: flex;
					flex-direction: column;
					align-items: center;
				}

				.right {
					width: 60px;
					display: flex;
					flex-direction: column;
					text-align: right;
					padding-right: 10px;
				}

				.name {
					color: #1F3F59;
					font-size: 14px;
				}

				.text {
					color: #8C9FAD;
				}
			}
		}
	}
</style>
